list_for_each_entry ( drhd, &acpi_drhd_units, list )
{
+ if ( drhd->segment != pdev->seg )
+ continue;
+
for (i = 0; i < drhd->scope.devices_cnt; i++)
if ( drhd->scope.devices[i] == PCI_BDF2(bus, devfn) )
return drhd;
return include_all;
}
-struct acpi_atsr_unit * acpi_find_matched_atsr_unit(u8 bus, u8 devfn)
+struct acpi_atsr_unit * acpi_find_matched_atsr_unit(u16 seg, u8 bus, u8 devfn)
{
struct acpi_atsr_unit *atsr;
struct acpi_atsr_unit *all_ports = NULL;
list_for_each_entry ( atsr, &acpi_atsr_units, list )
{
+ if ( atsr->segment != seg )
+ continue;
+
if ( test_bit(bus, atsr->scope.buses) )
return atsr;
}
-static int __init acpi_parse_dev_scope(void *start, void *end,
- void *acpi_entry, int type)
+static int __init acpi_parse_dev_scope(
+ void *start, void *end, void *acpi_entry, int type, u16 seg)
{
struct dmar_scope *scope = acpi_entry;
struct acpi_ioapic_unit *acpi_ioapic_unit;
bus, path->dev, path->fn, PCI_SUBORDINATE_BUS);
if ( iommu_verbose )
dprintk(VTDPREFIX,
- " bridge: %x:%x.%x start = %x sec = %x sub = %x\n",
- bus, path->dev, path->fn,
+ " bridge: %04x:%02x:%02x.%u start=%x sec=%x sub=%x\n",
+ seg, bus, path->dev, path->fn,
acpi_scope->start_bus, sec_bus, sub_bus);
dmar_scope_add_buses(scope, sec_bus, sub_bus);
case ACPI_DEV_MSI_HPET:
if ( iommu_verbose )
- dprintk(VTDPREFIX, " MSI HPET: %x:%x.%x\n",
- bus, path->dev, path->fn);
+ dprintk(VTDPREFIX, " MSI HPET: %04x:%02x:%02x.%u\n",
+ seg, bus, path->dev, path->fn);
break;
case ACPI_DEV_ENDPOINT:
if ( iommu_verbose )
- dprintk(VTDPREFIX, " endpoint: %x:%x.%x\n",
- bus, path->dev, path->fn);
+ dprintk(VTDPREFIX, " endpoint: %04x:%02x:%02x.%u\n",
+ seg, bus, path->dev, path->fn);
if ( type == DMAR_TYPE )
{
struct acpi_drhd_unit *drhd = acpi_entry;
- if ( (bus == 0) && (path->dev == 2) && (path->fn == 0) )
+ if ( (seg == 0) && (bus == 0) && (path->dev == 2) &&
+ (path->fn == 0) )
igd_drhd_address = drhd->address;
}
case ACPI_DEV_IOAPIC:
if ( iommu_verbose )
- dprintk(VTDPREFIX, " IOAPIC: %x:%x.%x\n",
- bus, path->dev, path->fn);
+ dprintk(VTDPREFIX, " IOAPIC: %04x:%02x:%02x.%u\n",
+ seg, bus, path->dev, path->fn);
if ( type == DMAR_TYPE )
{
memset(dmaru, 0, sizeof(struct acpi_drhd_unit));
dmaru->address = drhd->address;
+ dmaru->segment = drhd->segment;
dmaru->include_all = drhd->flags & 1; /* BIT0: INCLUDE_ALL */
INIT_LIST_HEAD(&dmaru->ioapic_list);
if ( iommu_verbose )
dev_scope_start = (void *)(drhd + 1);
dev_scope_end = ((void *)drhd) + header->length;
ret = acpi_parse_dev_scope(dev_scope_start, dev_scope_end,
- dmaru, DMAR_TYPE);
+ dmaru, DMAR_TYPE, drhd->segment);
if ( dmaru->include_all )
{
rmrru->base_address = base_addr;
rmrru->end_address = end_addr;
+ rmrru->segment = rmrr->segment;
dev_scope_start = (void *)(rmrr + 1);
dev_scope_end = ((void *)rmrr) + header->length;
ret = acpi_parse_dev_scope(dev_scope_start, dev_scope_end,
- rmrru, RMRR_TYPE);
+ rmrru, RMRR_TYPE, rmrr->segment);
if ( ret || (rmrru->scope.devices_cnt == 0) )
xfree(rmrru);
return -ENOMEM;
memset(atsru, 0, sizeof(struct acpi_atsr_unit));
+ atsru->segment = atsr->segment;
atsru->all_ports = atsr->flags & 1; /* BIT0: ALL_PORTS */
if ( iommu_verbose )
dprintk(VTDPREFIX,
dev_scope_start = (void *)(atsr + 1);
dev_scope_end = ((void *)atsr) + header->length;
ret = acpi_parse_dev_scope(dev_scope_start, dev_scope_end,
- atsru, ATSR_TYPE);
+ atsru, ATSR_TYPE, atsr->segment);
}
else
{
{
const char *reason;
int fault_type;
+ u16 seg = iommu->intel->drhd->segment;
reason = iommu_get_fault_reason(fault_reason, &fault_type);
if ( fault_type == DMA_REMAP )
{
INTEL_IOMMU_DEBUG(
- "DMAR:[%s] Request device [%02x:%02x.%d] "
+ "DMAR:[%s] Request device [%04x:%02x:%02x.%u] "
"fault addr %"PRIx64", iommu reg = %p\n"
"DMAR:[fault reason %02xh] %s\n",
(type ? "DMA Read" : "DMA Write"),
- (source_id >> 8), PCI_SLOT(source_id & 0xFF),
+ seg, (source_id >> 8), PCI_SLOT(source_id & 0xFF),
PCI_FUNC(source_id & 0xFF), addr, iommu->reg,
fault_reason, reason);
#ifndef __i386__ /* map_domain_page() cannot be used in this context */
}
else
INTEL_IOMMU_DEBUG(
- "INTR-REMAP: Request device [%02x:%02x.%d] "
+ "INTR-REMAP: Request device [%04x:%02x:%02x.%u] "
"fault index %"PRIx64", iommu reg = %p\n"
"INTR-REMAP:[fault reason %02xh] %s\n",
- (source_id >> 8), PCI_SLOT(source_id & 0xFF),
+ seg, (source_id >> 8), PCI_SLOT(source_id & 0xFF),
PCI_FUNC(source_id & 0xFF), addr >> 48, iommu->reg,
fault_reason, reason);
return 0;
struct hvm_iommu *hd = domain_hvm_iommu(domain);
struct context_entry *context, *context_entries;
u64 maddr, pgd_maddr;
+ u16 seg = iommu->intel->drhd->segment;
int agaw;
ASSERT(spin_is_locked(&pcidevs_lock));
/* First try to get domain ownership from device structure. If that's
* not available, try to read it from the context itself. */
- pdev = pci_get_pdev(0, bus, devfn);
+ pdev = pci_get_pdev(seg, bus, devfn);
if ( pdev )
{
if ( pdev->domain != domain )
unmap_vtd_domain_page(context_entries);
- me_wifi_quirk(domain, bus, devfn, MAP_ME_PHANTOM_FUNC);
+ if ( !seg )
+ me_wifi_quirk(domain, bus, devfn, MAP_ME_PHANTOM_FUNC);
return 0;
}
-static int domain_context_mapping(struct domain *domain, u8 bus, u8 devfn)
+static int domain_context_mapping(
+ struct domain *domain, u16 seg, u8 bus, u8 devfn)
{
struct acpi_drhd_unit *drhd;
int ret = 0;
u32 type;
u8 secbus;
- struct pci_dev *pdev = pci_get_pdev(0, bus, devfn);
+ struct pci_dev *pdev = pci_get_pdev(seg, bus, devfn);
drhd = acpi_find_matched_drhd_unit(pdev);
if ( !drhd )
case DEV_TYPE_PCIe_ENDPOINT:
if ( iommu_verbose )
- dprintk(VTDPREFIX, "d%d:PCIe: map bdf = %x:%x.%x\n",
- domain->domain_id, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
+ dprintk(VTDPREFIX, "d%d:PCIe: map %04x:%02x:%02x.%u\n",
+ domain->domain_id, seg, bus,
+ PCI_SLOT(devfn), PCI_FUNC(devfn));
ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn);
- if ( !ret && ats_device(0, bus, devfn) )
- enable_ats_device(0, bus, devfn);
+ if ( !ret && ats_device(seg, bus, devfn) )
+ enable_ats_device(seg, bus, devfn);
break;
case DEV_TYPE_PCI:
if ( iommu_verbose )
- dprintk(VTDPREFIX, "d%d:PCI: map bdf = %x:%x.%x\n",
- domain->domain_id, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
+ dprintk(VTDPREFIX, "d%d:PCI: map %04x:%02x:%02x.%u\n",
+ domain->domain_id, seg, bus,
+ PCI_SLOT(devfn), PCI_FUNC(devfn));
ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn);
if ( ret )
break;
default:
- dprintk(XENLOG_ERR VTDPREFIX, "d%d:unknown(%u): bdf = %x:%x.%x\n",
+ dprintk(XENLOG_ERR VTDPREFIX, "d%d:unknown(%u): %04x:%02x:%02x.%u\n",
domain->domain_id, type,
- bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
+ seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
ret = -EINVAL;
break;
}
spin_unlock(&iommu->lock);
unmap_vtd_domain_page(context_entries);
- me_wifi_quirk(domain, bus, devfn, UNMAP_ME_PHANTOM_FUNC);
+ if ( !iommu->intel->drhd->segment )
+ me_wifi_quirk(domain, bus, devfn, UNMAP_ME_PHANTOM_FUNC);
return 0;
}
-static int domain_context_unmap(struct domain *domain, u8 bus, u8 devfn)
+static int domain_context_unmap(
+ struct domain *domain, u16 seg, u8 bus, u8 devfn)
{
struct acpi_drhd_unit *drhd;
struct iommu *iommu;
int ret = 0;
u32 type;
u8 tmp_bus, tmp_devfn, secbus;
- struct pci_dev *pdev = pci_get_pdev(0, bus, devfn);
+ struct pci_dev *pdev = pci_get_pdev(seg, bus, devfn);
int found = 0;
BUG_ON(!pdev);
case DEV_TYPE_PCIe_ENDPOINT:
if ( iommu_verbose )
- dprintk(VTDPREFIX, "d%d:PCIe: unmap bdf = %x:%x.%x\n",
- domain->domain_id, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
+ dprintk(VTDPREFIX, "d%d:PCIe: unmap %04x:%02x:%02x.%u\n",
+ domain->domain_id, seg, bus,
+ PCI_SLOT(devfn), PCI_FUNC(devfn));
ret = domain_context_unmap_one(domain, iommu, bus, devfn);
- if ( !ret && ats_device(0, bus, devfn) )
- disable_ats_device(0, bus, devfn);
+ if ( !ret && ats_device(seg, bus, devfn) )
+ disable_ats_device(seg, bus, devfn);
break;
case DEV_TYPE_PCI:
if ( iommu_verbose )
- dprintk(VTDPREFIX, "d%d:PCI: unmap bdf = %x:%x.%x\n",
- domain->domain_id, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
+ dprintk(VTDPREFIX, "d%d:PCI: unmap %04x:%02x:%02x.%u\n",
+ domain->domain_id, seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
ret = domain_context_unmap_one(domain, iommu, bus, devfn);
if ( ret )
break;
break;
default:
- dprintk(XENLOG_ERR VTDPREFIX, "d%d:unknown(%u): bdf = %x:%x.%x\n",
+ dprintk(XENLOG_ERR VTDPREFIX, "d%d:unknown(%u): %04x:%02x:%02x.%u\n",
domain->domain_id, type,
- bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
+ seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
ret = -EINVAL;
goto out;
}
*/
for_each_pdev ( domain, pdev )
{
- if ( pdev->bus == bus && pdev->devfn == devfn )
+ if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == devfn )
continue;
drhd = acpi_find_matched_drhd_unit(pdev);
if ( (target != dom0) && !iommu_intremap )
untrusted_msi = 1;
- ret = domain_context_unmap(source, bus, devfn);
+ ret = domain_context_unmap(source, seg, bus, devfn);
if ( ret )
return ret;
- ret = domain_context_mapping(target, bus, devfn);
+ ret = domain_context_mapping(target, seg, bus, devfn);
if ( ret )
return ret;
if ( !pdev->domain )
return -EINVAL;
- ret = domain_context_mapping(pdev->domain, pdev->bus, pdev->devfn);
+ ret = domain_context_mapping(pdev->domain, pdev->seg, pdev->bus,
+ pdev->devfn);
if ( ret )
{
dprintk(XENLOG_ERR VTDPREFIX, "d%d: context mapping failed\n",
for_each_rmrr_device ( rmrr, bdf, i )
{
- if ( PCI_BUS(bdf) == pdev->bus && PCI_DEVFN2(bdf) == pdev->devfn )
+ if ( rmrr->segment == pdev->seg &&
+ PCI_BUS(bdf) == pdev->bus &&
+ PCI_DEVFN2(bdf) == pdev->devfn )
{
ret = rmrr_identity_mapping(pdev->domain, rmrr);
if ( ret )
{
for_each_rmrr_device ( rmrr, bdf, i )
{
- if ( PCI_BUS(bdf) == pdev->bus &&
+ if ( rmrr->segment == pdev->seg &&
+ PCI_BUS(bdf) == pdev->bus &&
PCI_DEVFN2(bdf) == pdev->devfn )
return 0;
}
}
- return domain_context_unmap(pdev->domain, pdev->bus, pdev->devfn);
+ return domain_context_unmap(pdev->domain, pdev->seg, pdev->bus,
+ pdev->devfn);
}
static void __init setup_dom0_devices(struct domain *d)
pdev->domain = d;
list_add(&pdev->domain_list, &d->arch.pdev_list);
- domain_context_mapping(d, pdev->bus, pdev->devfn);
+ domain_context_mapping(d, pdev->seg, pdev->bus, pdev->devfn);
pci_enable_acs(pdev);
pci_vtd_quirk(pdev);
}
/* FIXME: Because USB RMRR conflicts with guest bios region,
* ignore USB RMRR temporarily.
*/
- if ( is_usb_device(bus, devfn) )
+ if ( is_usb_device(seg, bus, devfn) )
{
ret = 0;
goto done;
/* Setup rmrr identity mapping */
for_each_rmrr_device( rmrr, bdf, i )
{
- if ( PCI_BUS(bdf) == bus && PCI_DEVFN2(bdf) == devfn )
+ if ( rmrr->segment == seg &&
+ PCI_BUS(bdf) == bus &&
+ PCI_DEVFN2(bdf) == devfn )
{
ret = rmrr_identity_mapping(d, rmrr);
if ( ret )